package org.dromara.web.controller.business;

import java.util.List;

import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import org.dromara.dao.business.domain.SmartAgentCategoryI18n;
import org.dromara.dao.business.domain.SmartAgentI18n;
import org.dromara.web.domain.vo.RemoveRequest;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.dao.business.domain.SmartAgentCategory;
import org.dromara.dao.business.domain.SmartAgentCategoryQuery;
import org.dromara.web.service.business.SmartAgentCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.dromara.common.mybatis.core.page.TableDataInfo;


/**
 * 智能体分类表 控制器
 *
 * @date 2025-01-13 10:09:10
 */
@Validated
@RestController
@RequestMapping("/common/smartAgentCategory")
public class SmartAgentCategoryController extends BaseController {

    @Autowired
    private SmartAgentCategoryService smartAgentCategoryService;

    /**
     * 查询智能体分类表列表
     * @SaCheckPermission("common:smartAgentCategory:list")
     */

    @GetMapping("/list")
    public TableDataInfo<SmartAgentCategory> list(SmartAgentCategoryQuery query, PageQuery pageQuery) {
        return smartAgentCategoryService.queryPageList(query, pageQuery);
    }




    /**
     * 获取智能体分类表详细信息
     *
     * @param id 主键
     * @SaCheckPermission("common:smartAgentCategory:query")
     */
    @GetMapping("/info")
    public R<SmartAgentCategory> getInfo(@NotNull(message = "主键不能为空")
                                     @RequestParam Long id) {
        return R.ok(smartAgentCategoryService.queryById(id));
    }

    /**
     * 新增智能体分类表
     * @SaCheckPermission("common:smartAgentCategory}:add")
     */

    @Log(title = "智能体分类表", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping("/add")
    public R<Void> add( @RequestBody SmartAgentCategory entity) {
        smartAgentCategoryService.insert(entity);
        return R.ok();
    }

    /**
     * 修改智能体分类表
     * @SaCheckPermission("common:smartAgentCategory:edit")
     */

    @Log(title = "智能体分类表", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PostMapping("/update")
    public R<Void> edit( @RequestBody SmartAgentCategory update) {
        smartAgentCategoryService.updateById(update);
        return R.ok();
    }

    /**
     * 删除智能体分类表
     *
     * @param req 主键串
     * @SaCheckPermission("common:smartAgentCategory:remove")
     */

    @Log(title = "智能体分类表", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    public R<Void> remove(@RequestBody RemoveRequest req) {
        smartAgentCategoryService.deleteByIds(req.getIds());
        return R.ok();
    }


    @GetMapping("/i18nList")
    public R<List<SmartAgentCategoryI18n>> i18ns(Long categoryId) {
        return R.ok(smartAgentCategoryService.listI18n(categoryId));
    }

    @PostMapping("/i18nInsert")
    public R<Void> i18nInsert(@RequestBody SmartAgentCategoryI18n entity) {
        smartAgentCategoryService.addI18n(entity);
        return R.ok();
    }


    @PostMapping("/i18nUpdate")
    public R<Void> i18nUpdate(@RequestBody SmartAgentCategoryI18n entity) {
        smartAgentCategoryService.updateI18n(entity);
        return R.ok();
    }

    @PostMapping("/i18nDelete")
    public R<Void> i18nDelete(@RequestBody SmartAgentI18n entity) {
        smartAgentCategoryService.deleteI18n(entity.getId());
        return R.ok();
    }

    @GetMapping("/all")
    public R<List<SmartAgentCategory>> all() {
        return R.ok(smartAgentCategoryService.queryAll());
    }
}
